#include <iostream>
using namespace std;
#include <list>

int main()
{
    list<int> mylist;

    /*尾插*/
    mylist.push_back(11);
    mylist.push_back(22);
    mylist.push_back(33);
    mylist.push_back(44);
    cout << "size:" << mylist.size() << endl;

    /*链表的头部元素。*/
    cout << "front:" << mylist.front() << endl;

    /*链表的尾部元素。*/
    cout << "back:" << mylist.back() << endl;

    /*链表头插 */
    mylist.push_front(-11);
    cout << "front:" << mylist.front() << endl;

    /* 头删 */
    mylist.pop_front();
    cout << "front:" << mylist.front() << endl;

    /*尾删 */
    mylist.pop_back();
    cout << "back:" << mylist.back() << endl;

    list<int> mylist2;
    mylist2.push_back(111);
    mylist2.push_back(222);
    mylist2.push_back(333);
    mylist2.push_back(444);

    /*链表合并 */
    mylist.merge(mylist2);

    /*链表的元素个数*/
    cout << "size:" << mylist.size() << endl;
    cout << "back:" << mylist.back() << endl;

    for (list<int>::iterator iter = mylist.begin(); iter !=mylist.end(); iter++)
    {
        cout<< "*iter:"<< *iter<< endl;
    }

    return 0;
}